{extend name="layout/detail" /}

{block name="content"}
<div class="td-content-wrap p20">
    <div class="td-content-header">
        <h1 class="main-title">添加文章分类</h1>
    </div>
    <hr>
    <div class="space-10"></div>
    <form id="form_data" class="layui-form" method="post" action="{:url('save')}">
        <input type="hidden" name="opmode" value="add">
        <div class="layui-form-item">
            <label class="layui-form-label required">名称：</label>
            <div class="layui-input-block w34">
                <input type="text" name="name" placeholder="请输入名称" class="layui-input" check="required"
                       info="请输入名称">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">上级分类：</label>
            <div class="layui-input-block w34">
                <input type="hidden" id="pid" name="pid">
                <input type="text" id="pid_name" name="pid_name" placeholder="请选择上级分类" class="layui-input"
                       check="required" info="请选择上级分类" readonly="readonly">
                <a class="add-on" onclick="select_pid();"><i class="fa fa-search"></i></a>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">栏目属性：</label>
            <div class="layui-input-block w19">
                <input type="radio" name="column" value="list" />列表模板<br>
                <input type="radio" name="column" value="article"/>文章模板<br>
                <input type="radio" name="column" value="url"/>跳转
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">列表模板：</label>
            <div class="layui-input-block w34">
                <input type="text" name="list_template" placeholder="请输入列表模板" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文章模板：</label>
            <div class="layui-input-block w34">
                <input type="text" name="article_template" placeholder="请输入文章模板" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">URL：</label>
            <div class="layui-input-block w34">
                <input type="text" name="url" placeholder="请输入URL" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">图标：</label>
            <div class="layui-input-inline">
                <input type="text" name="icon" placeholder="请输入图标" class="layui-input">
            </div>
            <div class="layui-form-mid">

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">图片：</label>
            <div class="layui-input-block">
                <div class="image-upload">
                    <div class="input">
                        <input type="hidden" class="image-url" name="image">
                    </div>
                    <div class="image-upload-btn">
                        上传图片
                    </div>
                    <div class="image">

                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序：</label>
            <div class="layui-input-block w8">
                <input type="text" name="sort" class="layui-input">
            </div>
        </div>
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <a class="layui-btn" lay-submit="" lay-filter="demo2" onclick="save();">保存</a>
                <a class="layui-btn layui-btn-primary" onclick="go_return_url();">取消</a>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script>
    layui.use(['form', 'element','uploader'], function () {
        var fn = {
            select_pid: function () {
                popup_open("{:url('select_pid')}", 560, 470);
            },
            save: function () {
                send_form("form_data", "{:url('save')}", function (res) {
                    if (res.code) {
                        layer.msg(res.msg, {
                            time: 1200
                        }, function () {
                            location.href = "{:url('index')}";
                        });
                    } else {
                        layer.msg(res.msg);
                        return false;
                    }
                });
            }
        };
        win_exp(fn);

    });
</script>
{/block}
